<template>
  <div id="app">
    <TodoHeader
      :isShow="isShow"
      @isShow="isShowFn"
      :records="records"
      @name="nameFn"
      @nameMask="nameMaskFn"
    ></TodoHeader>
    <TodoFooter :visible.sync="isShow" :arr="arr"></TodoFooter>
  </div>
</template>

<script>
import TodoHeader from './components/TodoHeader.vue'
import TodoFooter from './components//TodoFooter.vue'
export default {
  data() {
    return {
      records: [
        {
          date: '2022-01-01',
          doctor: '张三',
          diagnosis: '感冒',
          prescription: '感冒药'
        },
        {
          date: '2022-02-01',
          doctor: '李四',
          diagnosis: '头疼',
          prescription: '止疼药'
        },
        {
          date: '2022-03-01',
          doctor: '王五',
          diagnosis: '腰痛',
          prescription: '止痛贴'
        }
      ],
      isShow: false,
      arr: []
    }
  },
  methods: {
    isShowFn(value) {
      this.isShow = value
    },
    nameMaskFn(doctor) {
      this.arr = this.records.filter(item => item.doctor === doctor)
    },
    nameFn(value) {
      if (value) {
        this.records = this.records.filter(item => item.doctor === value)
      } else {
        this.records = [
          {
            date: '2022-01-01',
            doctor: '张三',
            diagnosis: '感冒',
            prescription: '感冒药'
          },
          {
            date: '2022-02-01',
            doctor: '李四',
            diagnosis: '头疼',
            prescription: '止疼药'
          },
          {
            date: '2022-03-01',
            doctor: '王五',
            diagnosis: '腰痛',
            prescription: '止痛贴'
          },
          {
            date: '2022-03-01',
            doctor: '赵四',
            diagnosis: '腰痛',
            prescription: '止痛贴'
          }
        ]
      }
    }
  },
  components: {
    TodoHeader,
    TodoFooter
  }
}
</script>

<style></style>
